package com.example.tcp.client.store;

import com.example.tcp.client.serde.Serde;
import com.example.tcp.client.store.impl.*;
import com.squareup.tape2.ObjectQueue;
import org.mapdb.Serializer;
import org.rocksdb.RocksDBException;

import java.io.IOException;

public class StoreFactory {

    public static <T> MemoryDequeStore<T> createMemoryDequeueStore() {
        return new MemoryDequeStore<>();
    }

    public static <T> MapDBFileQueueDequeStore<T> createMapDBFileQueueStore(final String filename, Serializer<T> serializer) {
        return new MapDBFileQueueDequeStore<>(filename, serializer);
    }

    public static <T> RocksDBFileQueueDequeStore<T> createRocksDBFileQueueStore(String dir, String name, Serde<T> serializer) throws RocksDBException {
        return new RocksDBFileQueueDequeStore<>(dir, name, serializer);
    }

    public static <T> Tap2FileQueueDequeStore<T> createTap2FileQueueStore(String filename, ObjectQueue.Converter<T> converter) throws IOException {
        return new Tap2FileQueueDequeStore<>(filename,  converter);
    }

    public static <T> BigQueueFileQueueDequeStore<T> createBigQueueFileQueueStore(String dir, String name, Serde<T> serde) throws IOException {
        return new BigQueueFileQueueDequeStore<>(dir, name, serde);
    }
}
